<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>slibc: Slibc API documentation</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">slibc
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li class="current"><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">Slibc API documentation </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h2><a class="anchor" id="intro_sec"></a>
Introduction</h2>
<p>This library provides an implementation of the bounds-checking C functions (as specified in Annex K of the current C standard, a.k.a. C11) for use with the GNU C library. These functions lower the risk of introducing security vulnerabilities such as buffer overflows and format string vulnerabilities into your code by providing clear and easy-to-use interfaces. For each C function a secure alternate function ending in a "_s" postfix is provided (e.g., strcpy_s). Use of these functions is recommended by security experts and secure coding standards</p>
<h2><a class="anchor" id="libinstall"></a>
Installing the library</h2>
<ul>
<li>Step 1: Download the package from the Downloads page. </li>
<li>Step 2: Extract it. </li>
<li>Step 3: Compile the slibc libary by typing make. At the moment two static libraries are created: libslibc.a and libslibc++.a . The latter is compiled with a C++ compiler. If you are developping a C++ application we recommend using the C++ version. </li>
<li>Step 4: Optionally, run all tests by executing make test.</li>
</ul>
<h2><a class="anchor" id="libusing"></a>
Using SLIBC with your program</h2>
<ul>
<li>Step 1: Use the new _s functions in your code: <div class="fragment"><pre class="fragment"><span class="preprocessor">    #include &lt;<a class="code" href="string_8h.html" title="Contains those _s-functions that are related to strings.">string.h</a>&gt;</span>
    <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])
    {
            <span class="keywordtype">char</span> dest[10];  
            <a class="code" href="string_8h.html#a8328d88ab6bc728a5d2768340470a86c" title="The strcpy_s function copies the string s2 to s1.">strcpy_s</a>(dest, <span class="keyword">sizeof</span>(dest), argv[0]);
    }
</pre></div></li>
</ul>
<ul>
<li>Step 2: When compiling include the slibc header directory (include/slibc) in your compiler's include path (e.g., add -I~/slibc/include/slibc). Remember that Annex K adds functions to the standard C library by extending existing header files. Slibc makes the fact that it's a third-party library (instead of being part of GLIBC) as transparent as possible to your program. To use strcpy_s, simply include <a class="el" href="string_8h.html" title="Contains those _s-functions that are related to strings.">string.h</a> in your program. It is important that your compiler searches in the slibc header directory first.</li>
</ul>
<ul>
<li>Step 3: Link your program to Slibc. Slibc is built as a shared library. Either add -lslibc or -lslibc++ (for the C++ version) to your linking step. Additionally, you might have to add the location of slibc's so-files to your Linker search path by adding -L (e.g., -L../src/).</li>
</ul>
<ul>
<li>Step 4: Run your program. If the Slibc shared object file cannot be found, you have to adjust the environment variable LD_LIBRARY_PATH. </li>
</ul>
</div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated on Wed Oct 31 2012 13:48:20 for slibc by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>
